home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14997 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: overloading and ellipsis
  5. Date: 3 Apr 1996 02:30:44 GMT
  6. Organization: Borland International
  7. Message-ID: <4jsnsk$mrh@druid.borland.com>
  8. References: <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>, 
  15. thuerman@informatik.uni-bremen.de says...
  16. >
  17. >I'd like to overload a function with ellipsis but g++ doesn't let me
  18. >do that.  Should that be possible?
  19. >
  20. >void send(char *fmt, ...)
  21. >{
  22. >        ;
  23. >}
  24. >
  25. >void send(char *fmt, va_list)
  26. >{
  27. >        ;
  28. >}
  29. >
  30. >void send(char *s)
  31. >{
  32. >        ;
  33. >}
  34. >
  35. >main()
  36. >{
  37. >        va_list ap;
  38. >
  39. >        send("abc %d\n", 13); // ok, calls first function
  40. >
  41. >        send("abc %d\n", ap); // ok, calls second function
  42. >
  43. >        send("abc\n");  // error:  ambiguous
  44. >}
  45. >
  46. >The second call is ok, because the argument ap does match better to
  47. >va_list than to "...", according to ARM r.13.2
  48. >
  49. >    [5] Match with ellipsis: Sequences that involve matches with
  50. >        ellipsis are worse than all others.
  51. >
  52. >This, of course sequences of conversion, so it doesn't apply to the
  53. >third call in my example where no conversion is neccessary.
  54. >But nevertheless I would think that the third function matches better
  55. >than the first for the third call in main(), so there would be exactly
  56. >one best match and the call legal.
  57. >Does the ARM say something about this, and is g++ correct?
  58.  
  59. The third function does not match better. There is one parameter, and both the 
  60. second and third versions of the function provide an exact match on that 
  61. parameter. There are no other parameters, so no other matches are considered. 
  62. The set of functions that match on the first parameter has more than one 
  63. member, so the call is ambiguous.
  64.  
  65.